/*
** resources.c for  in /u/all/tessa_b/cu/public/trantor
** 
** Made by arnaud1 tessa
** Login   <tessa_b@epitech.net>
** 
** Started on  Tue Jul  5 10:20:06 2011 arnaud1 tessa
** Last update Thu Jul  7 09:25:31 2011 arnaud1 tessa
*/

#include	<time.h>
#include	<stdlib.h>
#include	<stdio.h>
#include	<string.h>
#include	<strings.h>
#include	"resources.h"

#define		RESOURCE_MAX	2

void		resources_init(t_resources *r)
{
  struct timeval tv;
  
  gettimeofday(&tv, NULL);
  srand(tv.tv_usec);
  r->nourriture = rand() % RESOURCE_MAX;
  r->linemate = rand() % RESOURCE_MAX;
  r->deraumere = rand() % RESOURCE_MAX;
  r->sibur = rand() % RESOURCE_MAX;
  r->mendiane = rand() % RESOURCE_MAX;
  r->phiras = rand() % RESOURCE_MAX;
  r->thystame = rand() % RESOURCE_MAX;
}

char		*resources_to_string(t_resources *r)
{
  char		*str;

  str = malloc(64);
  if (str != NULL)
    {
      bzero(str, 64);
      if (r->nourriture > 0)
	strcat(str, " nourriture");
      if (r->linemate > 0)
	strcat(str, " linemate");
      if (r->deraumere > 0)
	strcat(str, " deraumere");
      if (r->sibur > 0)
	strcat(str, " sibur");
      if (r->mendiane > 0)
	strcat(str, " mendiane");
      if (r->phiras > 0)
	strcat(str, " phiras");
      if (r->thystame > 0)
	strcat(str, " thystame");
    }
  return (str);
}

/*
int		main()
{
  t_resources	t;
  t_resources	t2;

  resources_init(&t);
  resources_init(&t2);
  printf("%s\n", resources_to_string(&t));
  printf("%s\n", resources_to_string(&t2));
  printf("%s\n", resources_to_string(&t));
  printf("%s\n", resources_to_string(&t));
  printf("%s\n", resources_to_string(&t));
  return (0);
}
*/
